<!DOCTYPE html>
<html>
<head>
    <title>json.html</title>

    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <script type="text/javascript" src="/webDemo/js/utils.js"></script>//要导入才能用
    <script type="text/javascript" >
        function showUser(){
           document.writeln(this.name+" show(): " +this.no+","+this.age);
        }
        var user={"no":"A0001", //通过,分隔ｊｓｏｎ的属性、方法
            "name":"张三",
            "age": 25,
            "say":function(){
               document.writeln(this.name+" say:" +this.no+","+this.age);
            },
            "show":showUser
        };
       document.writeln(typeof user);
       document.writeln("user's name="+ user.name+",no="+user.no+",age="+user.age);
        user.say();//调用json对象的方法
        user.show();

        var student={"no":"A0001",
            "name":"张三",
            "age": 25,
            "classes":{"no":"T001",
                "name":"六年一班",
                "bzr":{"name":"陈平",
                    "subject":"语文"
                }
            },
            "subjects":[{"name":"语文","cj":95},
                {"name":"数学","cj":80},
                {"name":"英语","cj":90}
            ],
            "display":function(){
               document.writeln("学生的学号："+this.no+"学生的姓名："+this.name+"学生的年龄"+this.age)
               document.writeln( this.classes.name+",班主任："+this.classes.bzr.name+"教授课程："+this.classes.bzr.subject);
                for( var key in this.subjects)
                {
                   document.writeln(this.subjects[key].name+"的成绩："+this.subjects[key].cj );
                }

            }
            //显示ｓｔｕｄｅｎｔ个人信息及成绩列表

        };
        student.display();

    </script>

</head>

<body>

</body>
</html>
